/*******************************************************************************
*   Copyright (C) Harbin Institute of Technology, Shenzhen.
*				  All Rights Reserved.
*   Department: Decoration
********************************************************************************
* File Name   : sensor_if.h
* Author      : Dayuan
* Version     : v0.01
* Date        : 2019/9/2
* Description : Decoration Rototics Manipulator task.
*******************************************************************************/
/*-History----------------------------------------------------------------------
* Version   Date      Name        Changes and comments
* v0.01     2019/9/2  Dayuan    initial version
*=============================================================================*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef _SENSOR_IF_H_
#define _SENSOR_IF_H_

#ifdef __cplusplus
 extern "C" {
#endif
     
/**** Includes ****/
#include <stdint.h>
     
/**** Definition of constants ****/


 
/**** Definition of types ****/ 
typedef struct
{
	uint8_t rx_buf[9];
	uint8_t tx_buf[11];
	uint8_t rx_flag; /* 1-connected, 0-disconnected*/
	uint8_t addr;
	uint8_t fuc;
	uint8_t reg_add[2];
	uint8_t reg_byte;
	uint8_t reg_num[2];
	uint16_t txcrc;
	uint16_t rxcrc;
	uint16_t crc_error;
	uint16_t com_error;
	uint8_t over_time_error;
	uint8_t detect_valid;
	int32_t torque_raw;
	float torque;
	int8_t reg_write_success; /*1- begin change reg, 0- success, -1- some wrong*/
}SBT_FORCE;


/**** Definition of macros ****/


/**** Declaration of constants ****/


/**** Declaration of variables ****/
extern SBT_FORCE sbt_force;
extern uint32_t time_test;
/**** Declaration of functions ****/
extern void sbt_tx_complete_callback(void);
extern void sbt_rx_complete_callback(void);

extern int sbt_set_buat(uint32_t baut);
extern void sbt_set_zero(void);
extern void sbt_get_torque(void);
extern void sbt_get_buat(void);
extern void sbt_lock(void);
extern void sbt_unlock(void);

extern void sbt_control_polling(void);
extern void sbt_timeout_handle(void);
extern void sbt_initial(void);

#ifdef __cplusplus
}
#endif

#endif
